package com.hit.sys.modular.app.controller;

import com.hit.core.pojo.response.ResponseData;
import com.hit.core.pojo.response.SuccessResponseData;
import com.hit.sys.modular.app.param.SysAppParam;
import com.hit.sys.modular.app.service.SysAppService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class SysAppController {

    @Resource
    private SysAppService sysAppService;

    @GetMapping("/sysApp/page")
    public ResponseData page(SysAppParam sysAppParam) {
        return new SuccessResponseData(sysAppService.page(sysAppParam));
    }

    @PostMapping("/sysApp/add")
    public ResponseData add(@RequestBody @Validated(SysAppParam.add.class) SysAppParam sysAppParam){
        sysAppService.add(sysAppParam);
        return new SuccessResponseData();
    }

    @PostMapping("/sysApp/delete")
    public ResponseData delete(@RequestBody @Validated(SysAppParam.delete.class) SysAppParam sysAppParam){
        sysAppService.delete(sysAppParam);
        return new SuccessResponseData();
    }

    @PostMapping("/sysApp/edit")
    public ResponseData edit(@RequestBody @Validated(SysAppParam.edit.class) SysAppParam sysAppParam){
        sysAppService.edit(sysAppParam);
        return new SuccessResponseData();
    }

    @GetMapping("/sysApp/detail")
    public ResponseData detail(@Validated(SysAppParam.detail.class) SysAppParam sysAppParam){
        return new SuccessResponseData(sysAppService.detail(sysAppParam));
    }
}
